package top.shiyiri.exercise;

import top.shiyiri.bean.Student;
import top.shiyiri.preparedstatement.PreparedStatementQueryTest;

import java.util.Scanner;

/**
 * @author Aunean
 * @date 2022/1/19 17:04
 */
public class ExerciseTest3 {

    //根据身份证号或准考证号查询学生成绩信息
    public static void main(String[] args) {
        System.out.println("请选择您要输入的类型：");
        System.out.println("a:准考证号");
        System.out.println("b:身份证号");
        Scanner sc = new Scanner(System.in);
        String next = sc.next();

        if ("a".equalsIgnoreCase(next)) {
            System.out.println("请输入准考证号：");
            String info = sc.next();
            String sql = "select * from examStudent where ExamCard = ?";
            Student student = PreparedStatementQueryTest.getInstance(Student.class, sql, info);
            if (student == null) {
                System.out.println("查无此人，请重新输入");
            } else {
                System.out.println(student);
            }
        } else if ("b".equalsIgnoreCase(next)) {
            System.out.println("请输入学生的身份证号：");
            String info = sc.next();
            String sql = "select * from examStudent where IDCard = ?";
            Student student = PreparedStatementQueryTest.getInstance(Student.class, sql, info);
            System.out.println(student);
        } else {
            System.out.println("您的输入有误，请重新进入程序");
        }

        sc.close();
    }
}
